package com.shanzmoo.db.report.entity.vo;

import cn.hutool.core.date.LocalDateTimeUtil;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

/**
 * 首页统计信息
 *
 * @author： Gzhao 2021/1/23
 */
@Data
public class StatisticsVO {

    private MemberData memberData;
    private SpuData spuData;
    private OrderData orderData;
    private SalesData salesData;
    private String deadline;

    public void setMember(int memberTotal, int memberThisMonthAdd, int memberYesterdayAdd) {
        memberData = new MemberData();

        memberData.setTotal(memberTotal);
        memberData.setThisMonthAdd(memberThisMonthAdd);
        memberData.setYesterdayAdd(memberYesterdayAdd);
    }

    public void setSpu(int spuTotal, int spuOnSale, int spuOffSale) {
        spuData = new SpuData();

        spuData.setTotal(spuTotal);
        spuData.setOnSale(spuOnSale);
        spuData.setOffSale(spuOffSale);
    }

    public void setOrder(int outlet, int mall, int thirdPPlatform) {
        orderData = new OrderData();

        orderData.setOutlet(outlet);
        orderData.setMall(mall);
        orderData.setThirdPlatform(thirdPPlatform);
    }

    public void setSalesData(double salesOutlet, double salesMall, double salesThirdPlatform) {
        salesData = new SalesData();

        salesData.setOutlet(salesOutlet);
        salesData.setMall(salesMall);
        salesData.setThirdPlatform(salesThirdPlatform);

        deadline = LocalDateTimeUtil.format(LocalDateTimeUtil.offset(LocalDateTime.now(), -1, ChronoUnit.DAYS), "yyyy-MM-dd");
    }


    @Data
    public static class MemberData {
        private Integer total;
        private Integer thisMonthAdd;
        private Integer yesterdayAdd;
    }

    @Data
    public static class SpuData {
        private Integer total;
        private Integer onSale;
        private Integer offSale;
    }

    @Data
    public static class OrderData {
        private Integer outlet;
        private Integer mall;
        private Integer thirdPlatform;
    }

    @Data
    public static class SalesData {
        private double outlet;
        private double mall;
        private double thirdPlatform;
    }
}
